PowerTCP Mail for .NET
Send(Byte[]) Method
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > Tcp Class > Send Method : Send(Byte[]) Method




buffer
Source memory location for the data to send.
Send data to the server.

Syntax

Visual Basic (Declaration) 
<DescriptionAttribute("Send data from your buffer.")>
Public Overloads Function Send( _
   ByVal buffer() As Byte _
) As Segment
Visual Basic (Usage)Copy Code
Dim instance As Tcp
Dim buffer() As Byte
Dim value As Segment
 
value = instance.Send(buffer)
C# 
[DescriptionAttribute("Send data from your buffer.")]
public Segment Send( 
   byte[] buffer
)
Managed Extensions for C++ 
[DescriptionAttribute("Send data from your buffer.")]
public: Segment* Send( 
   byte[]* buffer
) 
C++/CLI 
[DescriptionAttribute("Send data from your buffer.")]
public:
Segment^ Send( 
   array<byte>^ buffer
) 

Parameters

buffer
Source memory location for the data to send.

Return Value

A Segment object encapsulating information about the data sent.

Exceptions

ExceptionDescription
System.ArgumentOutOfRangeExceptionoffset or count is less than 0.
System.ArgumentExceptionoffset + count is greater than the length of buffer.
System.Net.Sockets.SocketExceptionThe socket is not connected.

Example

The following example demonstrates sending bytes to the server.
Visual BasicCopy Code
Private Sub Test()
   ' Connect to an echo port
   Tcp1.Connect("atropos", 7)

   Dim sendbuffer() As Byte = System.Text.Encoding.Default.GetBytes("abcdefg")

   ' Send some bytes.
   Tcp1.Send(sendbuffer)

   Dim recvbuffer(sendbuffer.Length) As Byte

   ' Server will echo the bytes back. Receive the bytes.
   Tcp1.Receive(recvbuffer)

   ' Close the connection.
   Tcp1.Close()
End Sub
C#Copy Code
private void Test()
{
   // Connect to the echo port
   tcp1.Connect("atropos", 7);

   byte[] sendbuffer = System.Text.Encoding.Default.GetBytes("abcdefg");

   // Send some bytes.
   tcp1.Send(sendbuffer);

   byte[] recvbuffer = new byte[sendbuffer.Length];

   // Server will echo the bytes back. Receive the bytes.
   tcp1.Receive(recvbuffer);

   // Close the connection.
   tcp1.Close();
}

Remarks

After connecting, data can be received using the Tcp.Send method. All Tcp.Send methods return a Segment object, encapsulating information about the data sent such as the data sent, and the amount of bytes of data sent.

This method is functionally equivalent to Tcp.Stream.Write(byte[]).

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.